<template>
  <div class="recommend">
    <cube-scroll class="kaho-scroll" ref="scroll">
      <cube-slide :data="recommends" class="kaho-swiper">
        <cube-slide-item v-for="(item, index) in recommends" :key="index">
          <a :href="item.linkUrl">
            <img :src="item.picUrl">
          </a>
        </cube-slide-item>
      </cube-slide>
      <div  class="kaho-recommend-list">
        <div class="kaho-recommend-title">热门歌单推荐</div>
        <ul>
          <li class="flex kaho-item" v-for="(item, index) in discList" :key="index">
            <img :src="item.imgurl" alt="" class="kaho-img">
            <div class="kaho-text flex-1">
              <h2 class="kaho-name">{{item.creator.name}}</h2>
              <p class="kaho-desc">{{item.dissname}}</p>
            </div>
          </li>
        </ul>
        
      </div>
    </cube-scroll>
    <div class="loading-container flex-vertical flex-vertical-center" v-show="!discList.length">
      <cube-loading class="loading"></cube-loading>
      <p class="desc">正在载入...</p>
    </div>
  </div>
</template>
<script>
import {getRecommend, getDiscList} from '@/api/recommend'
import {ERR_OK} from '@/api/config'
import axios from 'axios'

export default {
  name: 'recommend',

  components: {

  },

  data() {
    return {
      recommends: [],
      discList: []
    }
  },

  methods: {
    _getRecommend() {
      getRecommend().then((res) => {
        if (res.code === ERR_OK) {
          this.recommends = res.data.slider
        }
      })
    },

    _getDiscList() {
      getDiscList().then((res) => {
        if (res.code === ERR_OK) {
          this.discList = res.data.list;
          // console.log(this.discList)
        }
      })
    },

  },

  created(){
    this._getRecommend();
    this._getDiscList();
    
  }

}
</script>
<style scoped lang="stylus">
.recommend{
  position: fixed;
  top: 88px;
  bottom: 0;
  left: 0;
  right: 0;

  .kaho-scroll{
    height: 100%;

    .kaho-swiper{
      width: 100vw;
      height: 40vw;
    }

    .kaho-recommend-list{
      position relative;

      .kaho-recommend-title{
        height: 65px;
        line-height: 65px;
        text-align: center;
        font-size: 14px;
        color: #ffcd32;
      }

      .kaho-item{
        box-sizing: border-box;
        padding: 0 20px 20px;

        .kaho-img{
          width: 60px;
          height: 60px;
          display: block;
          margin-right: 20px;
        }

        .kaho-text{
          line-height: 30px;
          overflow: hidden;
          font-size: 14px;

          .kaho-name{
            color: #fff;
          }

          .kaho-desc{
            color: hsla(0,0%,100%,.3);
          }
        }
      }

      
    }
  }

  .loading-container {
    position: absolute;
    width: 100%;
    top: 50%;
    transform: translateY(-50%);

    .loading-box {
      text-align: center;

      .loading {
        display: inline-block;
      }
    }

    .desc {
      width: 100%;
      line-height: 20px;
      font-size: 12px;
      color: hsla(0,0%,100%,.5);
      text-align: center;
      margin-top: 5px;
    }
  }
}

</style>